/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

function createXMLHTTP()
{
    var xmlhttp ;
    if (window.XMLHttpRequest)
    {   // IE7, FF, GC, O, S
        xmlhttp = new XMLHttpRequest();
    }
    else
    {
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    }
    return xmlhttp;
}

function banUser(get_parameter)
{
    var xmlhttp = createXMLHTTP();
    var parameter_array = parseString(get_parameter);
    var url = "redi.jsp?username="+parameter_array[0]+"&ban=1";
    xmlhttp.onreadystatechange=function()
    {
        if (xmlhttp.readyState==4)
        {
            document.getElementById("userlist").innerHTML =xmlhttp.responseText;
        }
    }
    //alert(url);
    xmlhttp.open("GET",url, true);
    xmlhttp.send();
}

function unBanUser(get_parameter)
{
    var xmlhttp = createXMLHTTP();
    var parameter_array = parseString(get_parameter);
    var url = "redi.jsp?username="+parameter_array[0]+"&ban=0";
    xmlhttp.onreadystatechange=function()
    {
        if (xmlhttp.readyState==4)
        {
            document.getElementById("userlist").innerHTML =xmlhttp.responseText;
        }
    }
    //alert(url);
    xmlhttp.open("GET",url, true);
    xmlhttp.send();
}

function makeAdmin(get_parameter)
{
    var xmlhttp = createXMLHTTP();
    var parameter_array = parseString(get_parameter);
    var url = "redi.jsp?username="+parameter_array[0]+"&admin=admin";
    xmlhttp.onreadystatechange=function()
    {
        if (xmlhttp.readyState==4)
        {
            document.getElementById("userlist").innerHTML =xmlhttp.responseText;
        }
    }
    //alert(url);
    xmlhttp.open("GET",url, true);
    xmlhttp.send();
}

function makeModerator(get_parameter)
{
    var xmlhttp = createXMLHTTP();
    var parameter_array = parseString(get_parameter);
    var url = "redi.jsp?username="+parameter_array[0]+"&privilege=moderator";
    xmlhttp.onreadystatechange=function()
    {
        if (xmlhttp.readyState==4)
        {
            document.getElementById("userlist").innerHTML =xmlhttp.responseText;
        }
    }
    //alert(url);
    xmlhttp.open("GET",url, true);
    xmlhttp.send();
}

function unMakeModerator(get_parameter)
{
    var xmlhttp = createXMLHTTP();
    var parameter_array = parseString(get_parameter);
    var url = "redi.jsp?username="+parameter_array[0]+"&privilege=user";
    xmlhttp.onreadystatechange=function()
    {
        if (xmlhttp.readyState==4)
        {
            document.getElementById("userlist").innerHTML =xmlhttp.responseText;
        }
    }
    //alert(url);
    xmlhttp.open("GET",url, true);
    xmlhttp.send();
}

function parseString(maudiparsing)
{
    var tes2_array = maudiparsing.toString().split("#");
    return tes2_array;
}

function addSub(namasub,idparent)
{
    var xmlhttp = createXMLHTTP();
    var url = "loadkategoriadmin.jsp?idparent=" + idparent + "&namasub=" + namasub;
    xmlhttp.onreadystatechange=function()
    {
        if (xmlhttp.readyState==4)
        {
            document.getElementById("categorylist").innerHTML =xmlhttp.responseText;
            popup('addSub');
        }
    }
    
    //alert(url);
    xmlhttp.open("GET",url, true);
    xmlhttp.send();
}

function addCat(namasub,idparent)
{
    var xmlhttp = createXMLHTTP();
    var url = "loadkategoriadmin.jsp?idparent=" + idparent + "&namasub=" + namasub;
    xmlhttp.onreadystatechange=function()
    {
        if (xmlhttp.readyState==4)
        {
            document.getElementById("categorylist").innerHTML =xmlhttp.responseText;
            popup('addCat');
        }
    }

    //alert(url);
    xmlhttp.open("GET",url, true);
    xmlhttp.send();
}

function delCat(id)
{
    var xmlhttp = createXMLHTTP();
    var url = "delkategori.jsp?id=" + id;
    xmlhttp.onreadystatechange=function()
    {
        if (xmlhttp.readyState==4)
        {
            document.getElementById("categorylist").innerHTML =xmlhttp.responseText;
        }
    }

    //alert(url);
    xmlhttp.open("GET",url, true);
    xmlhttp.send();
}

function maxroom(value)
{
    var xmlhttp = createXMLHTTP();
    var url = "maxroom.jsp?value=" + value;
    xmlhttp.onreadystatechange=function()
    {
        if (xmlhttp.readyState==4)
        {
            popup('maxroom');
        }
    }

    //alert(url);
    xmlhttp.open("GET",url, true);
    xmlhttp.send();
}